package com.zhuxulin.nokia;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;

public class OrderDetail implements CommandListener {
	private Display dis = null;
	private List msgList = null;
	public Command backCMD;
	private Displayable parent;
	private String loginName;
	private String passwordP;
	private Order order;

	public OrderDetail(Display dis, Displayable parent, String loginName, String password, Order order) {
		this.dis = dis;
		this.parent = parent;
		this.loginName = loginName;
		this.passwordP = password;
		this.order = order;
		init();
	}

	private void init() {
		if (this.dis != null) {
			String[] msgArr;
			if (("".equals(this.order.getNumber2())) && ("".equals(this.order.getNumber3())) && ("".equals(this.order.getNumber4()))
					&& ("".equals(this.order.getNumber5()))) {
				msgArr = new String[6];
				msgArr[0] = this.order.getOrderId();
				msgArr[1] = this.order.getOrderDate();
				msgArr[2] = this.order.getWinningDate();
				msgArr[3] = this.order.getCompany();
				msgArr[4] = this.order.getNumber1();
				msgArr[5] = this.order.getAggregateAmount();
			} else if (("".equals(this.order.getNumber3())) && ("".equals(this.order.getNumber4())) && ("".equals(this.order.getNumber5()))) {
				msgArr = new String[7];
				msgArr[0] = this.order.getOrderId();
				msgArr[1] = this.order.getOrderDate();
				msgArr[2] = this.order.getWinningDate();
				msgArr[3] = this.order.getCompany();
				msgArr[4] = this.order.getNumber1();
				msgArr[5] = this.order.getNumber2();
				msgArr[6] = this.order.getAggregateAmount();
			} else if (("".equals(this.order.getNumber4())) && ("".equals(this.order.getNumber5()))) {
				msgArr = new String[8];
				msgArr[0] = this.order.getOrderId();
				msgArr[1] = this.order.getOrderDate();
				msgArr[2] = this.order.getWinningDate();
				msgArr[3] = this.order.getCompany();
				msgArr[4] = this.order.getNumber1();
				msgArr[5] = this.order.getNumber2();
				msgArr[6] = this.order.getNumber3();
				msgArr[7] = this.order.getAggregateAmount();
			} else if ("".equals(this.order.getNumber5())) {
				msgArr = new String[9];
				msgArr[0] = this.order.getOrderId();
				msgArr[1] = this.order.getOrderDate();
				msgArr[2] = this.order.getWinningDate();
				msgArr[3] = this.order.getCompany();
				msgArr[4] = this.order.getNumber1();
				msgArr[5] = this.order.getNumber2();
				msgArr[6] = this.order.getNumber3();
				msgArr[7] = this.order.getNumber4();
				msgArr[8] = this.order.getAggregateAmount();
			} else {
				msgArr = new String[10];
				msgArr[0] = this.order.getOrderId();
				msgArr[1] = this.order.getOrderDate();
				msgArr[2] = this.order.getWinningDate();
				msgArr[3] = this.order.getCompany();
				msgArr[4] = this.order.getNumber1();
				msgArr[5] = this.order.getNumber2();
				msgArr[6] = this.order.getNumber3();
				msgArr[7] = this.order.getNumber4();
				msgArr[8] = this.order.getNumber5();
				msgArr[9] = this.order.getAggregateAmount();
			}
			this.msgList = new List("Order Detail", 3, msgArr, null);
			this.backCMD = new Command("Back", 2, 1);
			this.msgList.addCommand(this.backCMD);
			this.msgList.setCommandListener(this);
			this.dis.setCurrent(this.msgList);
		}
	}

	public void commandAction(Command cmnd, Displayable dsplbl) {
		if (cmnd == this.backCMD)
			this.dis.setCurrent(this.parent);
	}
}